home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F30770_strSplittoWords.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-02-27  |  1.8 KB  |  55 lines

  1. ∩╗┐<xsl:stylesheet version="1.0"
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  4. xmlns:str-split2words-func="f:str-split2words-func"
  5. exclude-result-prefixes="xsl msxsl str-split2words-func"
  6. >
  7.  
  8.    <xsl:import href="str-foldl.xsl"/>
  9.  
  10.    <str-split2words-func:str-split2words-func/>
  11.  
  12.     <xsl:template name="str-split-to-words">
  13.       <xsl:param name="pStr"/>
  14.       <xsl:param name="pDelimiters"/>
  15.       
  16.       <xsl:variable name="vsplit2wordsFun"
  17.                     select="document('')/*/str-split2words-func:*[1]"/>
  18.                     
  19.       <xsl:variable name="vrtfParams">
  20.        <delimiters><xsl:value-of select="$pDelimiters"/></delimiters>
  21.       </xsl:variable>
  22.  
  23.       <xsl:variable name="vResult">
  24.           <xsl:call-template name="str-foldl">
  25.             <xsl:with-param name="pFunc" select="$vsplit2wordsFun"/>
  26.             <xsl:with-param name="pStr" select="$pStr"/>
  27.             <xsl:with-param name="pA0" select="msxsl:node-set($vrtfParams)"/>
  28.           </xsl:call-template>
  29.       </xsl:variable>
  30.       
  31.       <xsl:copy-of select="msxsl:node-set($vResult)/word"/>
  32.  
  33.     </xsl:template>
  34.  
  35.     <xsl:template match="str-split2words-func:*">
  36.       <xsl:param name="arg1" select="/.."/>
  37.       <xsl:param name="arg2"/>
  38.          
  39.       <xsl:copy-of select="msxsl:node-set($arg1)/*[1]"/>
  40.       <xsl:copy-of select="msxsl:node-set($arg1)/word[position() != last()]"/>
  41.       
  42.       <xsl:choose>
  43.         <xsl:when test="contains($arg1/*[1], $arg2)">
  44.           <xsl:if test="string($arg1/word[last()])">
  45.              <xsl:copy-of select="$arg1/word[last()]"/>
  46.           </xsl:if>
  47.           <word/>
  48.         </xsl:when>
  49.         <xsl:otherwise>
  50.           <word><xsl:value-of select="concat($arg1/word[last()], $arg2)"/></word>
  51.         </xsl:otherwise>
  52.       </xsl:choose>
  53.     </xsl:template>
  54.  
  55. </xsl:stylesheet>